package com.bw.a1908.base;

import com.blankj.utilcode.util.LogUtils;
import com.bw.a1908.core.mvp.BaseFragment;
import com.bw.a1908.core.mvp.IPresenter;

public abstract class LazyFragment<P extends IPresenter> extends BaseFragment<P> {

    //Fragment v4 or androidx
    //ViewPager Adapter
    @Override
    public void setUserVisibleHint(boolean isVisibleToUser) {
        super.setUserVisibleHint(isVisibleToUser);
    }

    /**
     * 用户是否可见
     */
    public void onUserStatue(boolean isShow) {

    }

    /**
     * 懒加载部分 （页面第一次展示时）
     */
    protected abstract void lazy();


    private boolean isFirst = true;

    @Override
    public void onResume() {
        super.onResume();
        if (isFirst){
            lazy();
            isFirst = false;
        }
        onUserStatue(true);
    }

    @Override
    public void onPause() {
        super.onPause();
        onUserStatue(false);
    }
}
